package config

import (
	"github.com/BurntSushi/toml"
	"log"
	"path/filepath"
	"sync"
)


var (
	C *Sconfig
	once sync.Once
)

type Sconfig struct {
	ServerPort		string
	Rc4Key		string
	Sqlip		string
	Sqlport		string
	Sqluser		string
	Sqlpwd		string
	Sqldata1	string
	Sqldata2	string
	Sqldata3	string
	RegStart	bool
	ModifyStart	bool
	CdkStart	bool
	PdStart		bool
	Gg			string
	Gname		string
	Version		string
	QdStart		string
	Gd			string
	Qq			string
	Cz			string
	IPLock		int
	Jyb			int
	Yyb			int
	Privilege	int
	Pjyb		int
	Pyyb		int
}


func Config () *Sconfig {
	once.Do(func() {
		filePath, err := filepath.Abs("./config.toml")
		if err != nil {
			log.Fatal("读取配置文件失败！",err)
		}
		if  _, err := toml.DecodeFile(filePath, &C); err != nil {
			log.Fatal("读取配置文件失败！",err)
		}
	})

	return C
}

